<?php

use yii\db\Migration;

class m180607_072121_create_customer_upgrade_type extends Migration
{
    public function safeUp()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB';
        }
        $this->createTable('{{%customer_upgrade_type}}', [
            'id' => $this->primaryKey()->notNull()->comment('自增id'),
            'name' => $this->string(100)->defaultValue(null)->comment('类型名称'),
            'description' => $this->string(255)->defaultValue(null)->comment('描述'),
            'status' => $this->smallInteger(2)->defaultValue(1)->comment('状态 （1 启用 2 禁用）'),
            'cerated_at' => $this->integer()->defaultValue(0)->comment('充值时间'),
        ],$tableOptions);

    }

    public function safeDown()
    {
        $this->dropTable('{{%customer_upgrade_type}}');
        $this->dropTable('{{%customer_upgrade_rule}}');
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m180607_072121_create_customer_upgrade_type cannot be reverted.\n";

        return false;
    }
    */
}
